package com.banciyuan.bcywebview.biz.main.mainpage.timeline;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.os.Build;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.android.volley.RequestQueue;
import com.banciyuan.bcywebview.R;
import com.banciyuan.bcywebview.base.factory.TimelineFactory;
import com.banciyuan.bcywebview.base.helper.data.UserDataHelper;
import com.banciyuan.bcywebview.base.helper.push.PushDataHelper;
import com.banciyuan.bcywebview.base.helper.timelinedatacenter.DetailDataHelper;
import com.banciyuan.bcywebview.base.helper.timelinedatacenter.TimelineLikeHelper;
import com.banciyuan.bcywebview.base.util.BaseObserver;
import com.banciyuan.bcywebview.base.util.BaseWatcher;
import com.banciyuan.bcywebview.base.view.dialog.ConfirmDialog;
import com.banciyuan.bcywebview.base.view.dialog.TimelineBanDialog;
import com.banciyuan.bcywebview.base.view.tag.TagView;
import com.banciyuan.bcywebview.base.view.textview.EllipsezeTextView;
import com.banciyuan.bcywebview.base.view.toast.MyToast;
import com.banciyuan.bcywebview.biz.ask.AskActivity;
import com.banciyuan.bcywebview.biz.circles.CircleLikeHelper;
import com.banciyuan.bcywebview.biz.circles.discover.DiscoverCircleActivity;
import com.banciyuan.bcywebview.biz.circles.smooth.CircleSmoothActivity;
import com.banciyuan.bcywebview.biz.circles.smooth.CircleTagSmoothActivity;
import com.banciyuan.bcywebview.biz.detail.goods.GoodsDetailActivity;
import com.banciyuan.bcywebview.biz.event.EventDetailActivity;
import com.banciyuan.bcywebview.biz.groupdetail.NewTeamDetailActivity;
import com.banciyuan.bcywebview.biz.main.mainpage.timeline.viewholder.BaseView;
import com.banciyuan.bcywebview.biz.main.mainpage.timeline.viewholder.LocalCircleHolder;
import com.banciyuan.bcywebview.biz.main.mainpage.timeline.viewholder.ViewArticle;
import com.banciyuan.bcywebview.biz.main.mainpage.timeline.viewholder.ViewAsk;
import com.banciyuan.bcywebview.biz.main.mainpage.timeline.viewholder.ViewAskMore;
import com.banciyuan.bcywebview.biz.main.mainpage.timeline.viewholder.ViewCircle;
import com.banciyuan.bcywebview.biz.main.mainpage.timeline.viewholder.ViewDaily;
import com.banciyuan.bcywebview.biz.main.mainpage.timeline.viewholder.ViewEmpty;
import com.banciyuan.bcywebview.biz.main.mainpage.timeline.viewholder.ViewGoods;
import com.banciyuan.bcywebview.biz.main.mainpage.timeline.viewholder.ViewGroupTeam;
import com.banciyuan.bcywebview.biz.main.mainpage.timeline.viewholder.ViewHolder;
import com.banciyuan.bcywebview.biz.main.mainpage.timeline.viewholder.ViewLastView;
import com.banciyuan.bcywebview.biz.main.mainpage.timeline.viewholder.ViewMoreBan;
import com.banciyuan.bcywebview.biz.main.mainpage.timeline.viewholder.ViewPost;
import com.banciyuan.bcywebview.biz.main.mainpage.timeline.viewholder.ViewSpot;
import com.banciyuan.bcywebview.biz.main.mainpage.timeline.viewholder.ViewTopic;
import com.banciyuan.bcywebview.biz.main.mainpage.timeline.viewholder.ViewVideo;
import com.banciyuan.bcywebview.biz.main.mainpage.timeline.viewholder.ViewWriter;
import com.banciyuan.bcywebview.biz.pc.TeamsActivity;
import com.banciyuan.bcywebview.biz.pc.zone.smooth.SmoothPersonActivity;
import com.banciyuan.bcywebview.biz.report.ReportActivity;
import com.banciyuan.bcywebview.biz.setting.MainSettingActivity;
import com.banciyuan.bcywebview.biz.share.block.BlockHelper;
import com.banciyuan.bcywebview.biz.share.block.IBlockHelper;
import com.banciyuan.bcywebview.biz.share.block.SimpleBlockImpl;
import com.banciyuan.bcywebview.biz.topic.TopicDetailActivity;
import com.banciyuan.bcywebview.biz.topic.TopicDetailListActivity;
import com.banciyuan.bcywebview.utils.common.UIUtils;
import com.banciyuan.bcywebview.utils.constants.MyConstants;
import com.banciyuan.bcywebview.utils.currency.CurrencyUtil;
import com.banciyuan.bcywebview.utils.http.HttpUtils;
import com.banciyuan.bcywebview.utils.http.StatusCodeUtils;
import com.banciyuan.bcywebview.utils.http.VolleyQueue;
import com.banciyuan.bcywebview.utils.intent.gotoUtil;
import com.banciyuan.bcywebview.utils.string.NoLineClickSpan;
import com.banciyuan.bcywebview.utils.string.StringUtil;
import com.banciyuan.bcywebview.utils.universalimageloader.core.ImageLoader;
import com.banciyuan.bcywebview.utils.universalimageloader.utils.ImageOptions;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import de.greenrobot.daoexample.model.Detail;
import de.greenrobot.daoexample.model.TagDetail;
import de.greenrobot.daoexample.model.Timeline;
import de.greenrobot.daoexample.model.TimelineCircle;

/**
 * Created by hy on 2015/7/22.
 */
public class TimelineListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements BaseWatcher {

    private Context mContext;
    private LinkedList<Timeline> tlist = new LinkedList<>();
    private RequestQueue mQueue;
    private View.OnClickListener onRefreashClick;
    private boolean isAnimation_runing = false;
    private List<String> ban_list = new ArrayList<>();

    public TimelineListAdapter(Context mContext, LinkedList<Timeline> tlist) {
        this.mContext = mContext;
        this.tlist = tlist;
        mQueue = VolleyQueue.getRquest(mContext);
        BaseObserver.getInstance().addWatcher(TimelineListAdapter.class, this);
    }

    public void setOnRefreashClick(View.OnClickListener onRefreashClick) {
        this.onRefreashClick = onRefreashClick;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        switch (viewType) {
            case TimelineCardType.COSILL_CARD:
            default:
                return new ViewHolder(View.inflate(mContext, R.layout.ground_list_item, null));
            case TimelineCardType.DAILY_CARD:
                return new ViewDaily(View.inflate(mContext, R.layout.new_daily_list_item, null));
            case TimelineCardType.ASK_CARD:
                return new ViewAsk(View.inflate(mContext, R.layout.timeline_ask_list_item, null));
            case TimelineCardType.WRITER_CARD:
                return new ViewWriter(View.inflate(mContext, R.layout.timeline_writer_list_item, null));
            case TimelineCardType.ASK_MORE_CARD:
                return new ViewAskMore(View.inflate(mContext, R.layout.timeline_ask_more_item, null));
            case TimelineCardType.GROUP_CARD:
                return new ViewGroupTeam(View.inflate(mContext, R.layout.timeline_groupteam_item, null));
            case TimelineCardType.GROUP_POST_CARD:
                return new ViewPost(View.inflate(mContext, R.layout.new_post_list_item, null));
            case TimelineCardType.SPOT_CARD:
                return new ViewSpot(View.inflate(mContext, R.layout.timeline_newspot, null));
            case TimelineCardType.CIRCLE_CARD:
                return new ViewCircle(View.inflate(mContext, R.layout.timeline_circle_item, null));
            case TimelineCardType.EMPTY_CARD:
                return new ViewEmpty(View.inflate(mContext, R.layout.timeline_empty_item, null));
            case TimelineCardType.GOODS_CARD:
                return new ViewGoods(View.inflate(mContext, R.layout.timeline_goods_item, null));
            case TimelineCardType.ARTICLE_CARD:
                return new ViewArticle(View.inflate(mContext, R.layout.timeline_article_item, null));
            case TimelineCardType.LAST_VIEW_CARD:
                return new ViewLastView(LayoutInflater.from(mContext).inflate(R.layout.timeline_lastview_notice, parent, false));
            case TimelineCardType.TOPIC_CARD:
                return new ViewTopic(View.inflate(mContext, R.layout.timeline_topic_item, null));
            case TimelineCardType.MORE_BAN:
                return new ViewMoreBan(View.inflate(mContext, R.layout.timeline_ban_after_item, null));
            case TimelineCardType.VIDEO_CARD:
                return new ViewVideo(View.inflate(mContext, R.layout.timeline_video_item, null));
            case TimelineCardType.LOCAL_CIRCLE:
                return new LocalCircleHolder(View.inflate(mContext, R.layout.timeline_local_circles, null));
        }
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (position == 0) {
            LocalCircleHolder localCircleHolder = (LocalCircleHolder) holder;
            localCircleHolder.renderData(mContext);
        } else {
            int index = position - 1;
            Timeline mItem = tlist.get(index);
            switch (getItemViewType(position)) {
                case TimelineCardType.COSILL_CARD:
                default:
                    setCosIllust((ViewHolder) holder, mItem, index);
                    break;
                case TimelineCardType.DAILY_CARD:
                    setDaily((ViewDaily) holder, mItem, index);
                    break;
                case TimelineCardType.ASK_CARD:
                    setAsk((ViewAsk) holder, mItem, index);
                    break;
                case TimelineCardType.WRITER_CARD:
                    setWriter((ViewWriter) holder, mItem, index);
                    break;
                case TimelineCardType.ASK_MORE_CARD:
                    setAskMore((ViewAskMore) holder, mItem, index);
                    break;
                case TimelineCardType.GROUP_CARD:
                    setGroup((ViewGroupTeam) holder, mItem, index);
                    break;
                case TimelineCardType.GROUP_POST_CARD:
                    setGroupPost((ViewPost) holder, mItem, index);
                    break;
                case TimelineCardType.SPOT_CARD:
                    setSpot((ViewSpot) holder, mItem);
                    break;
                case TimelineCardType.CIRCLE_CARD:
                    setCircle((ViewCircle) holder, mItem, index);
                    break;
                case TimelineCardType.EMPTY_CARD:
                    setEmpty((ViewEmpty) holder);
                    break;
                case TimelineCardType.GOODS_CARD:
                    setGoods((ViewGoods) holder, mItem, index);
                    break;
                case TimelineCardType.ARTICLE_CARD:
                    setArticle((ViewArticle) holder, mItem, index);
                    break;
                case TimelineCardType.LAST_VIEW_CARD:
                    setLastView((ViewLastView) holder);
                    break;
                case TimelineCardType.TOPIC_CARD:
                    setTopic((ViewTopic) holder, mItem, index);
                    break;
                case TimelineCardType.MORE_BAN:
                    setBan((ViewMoreBan) holder, mItem, index);
                    break;
                case TimelineCardType.VIDEO_CARD:
                    setVideo((ViewVideo) holder, mItem, index);
                    break;
            }
        }
    }

    @Override
    public int getItemViewType(int position) {
        if (position == 0) {
            return TimelineCardType.LOCAL_CIRCLE;
        } else {
            Timeline mItem = tlist.get(position - 1);
            switch (TimelineFactory.whichType(mItem)) {
                case TimelineFactory.TIMELINE_TYPE_ILLUST:
                case TimelineFactory.TIMELINE_TYPE_COSER:
                default:
                    return TimelineCardType.COSILL_CARD;
                case TimelineFactory.TIMELINE_TYPE_DAILY:
                    if (StringUtil.notNullEqual(mItem.getType(), "larticle")) {
                        return TimelineCardType.ARTICLE_CARD;
                    } else if (StringUtil.notNullEqual(mItem.getType(), "svideo")) {
                        return TimelineCardType.VIDEO_CARD;
                    } else {
                        return TimelineCardType.DAILY_CARD;
                    }
                case TimelineFactory.TIMELINE_TYPE_ASK:
                    if (null != mItem.getDetails() && mItem.getDetails().size() >= 3) {
                        return TimelineCardType.ASK_MORE_CARD;
                    } else {
                        return TimelineCardType.ASK_CARD;
                    }
                case TimelineFactory.TIMELINE_TYPE_WRITER:
                    return TimelineCardType.WRITER_CARD;
                case TimelineFactory.TIMELINE_TYPE_GROUP_TEAM:
                    return TimelineCardType.GROUP_CARD;
                case TimelineFactory.TIMELINE_TYPE_GROUP:
                    return TimelineCardType.GROUP_POST_CARD;
                case TimelineFactory.TIMELINE_TYPE_SPOT_TAG:
                case TimelineFactory.TIMELINE_TYPE_SPOT_WORK:
                case TimelineFactory.TIMELINE_TYPE_SPOT_TEXT:
                    return TimelineCardType.SPOT_CARD;
                case TimelineFactory.TIMELINE_TYPE_CIRCLE:
                    return TimelineCardType.CIRCLE_CARD;
                case TimelineFactory.TIMELINE_TYPE_EMPTY:
                    return TimelineCardType.EMPTY_CARD;
                case TimelineFactory.TIMELINE_TYPE_GOODS:
                    return TimelineCardType.GOODS_CARD;
                case TimelineFactory.TIMELINE_TYPE_LAST_VIEW:
                    return TimelineCardType.LAST_VIEW_CARD;
                case TimelineFactory.TIMELINE_TYPE_MORE_BAN:
                    return TimelineCardType.MORE_BAN;
            }
        }
    }

    @Override
    public int getItemCount() {
        if (tlist == null) return 1;
        else {
            return tlist.size() + 1;
        }
    }

    private void setTopic(ViewTopic mViewTopic, Timeline timeline, int position) {
        ImageLoader.getInstance().displayImage(timeline.getCover(), mViewTopic.cover, ImageOptions.options);
        if (!TextUtils.isEmpty(timeline.getTitle())) {
            mViewTopic.title.setText(Html.fromHtml(timeline.getTitle()));
        }
        if (!TextUtils.isEmpty(timeline.getPlain())) {
            mViewTopic.intro.setText(Html.fromHtml(timeline.getPlain()));
        }
        OnClick groundOnClick = new OnClick(position);
        mViewTopic.cover.setOnClickListener(groundOnClick);
        mViewTopic.click_line.setOnClickListener(groundOnClick);
    }

    private void setLastView(ViewLastView mViewLastView) {
        mViewLastView.itemView.setOnClickListener(onRefreashClick);
    }

    private void setVideo(ViewVideo mViewVideo, Timeline mItem, int position) {
        ImageLoader.getInstance().displayImage(mItem.getContentAddress(), mViewVideo.content, ImageOptions.optionsTimeline, null, null, false);
        if (!TextUtils.isEmpty(mItem.getTitle())) {
            mViewVideo.title.setVisibility(View.VISIBLE);
            mViewVideo.title.setText(Html.fromHtml(mItem.getTitle()));
        } else {
            mViewVideo.title.setVisibility(View.GONE);
        }
        try {
            String time = StringUtil.getTimeDuration((int) Double.parseDouble(mItem.getVideo_info().getDuration()));
            mViewVideo.pageNum.setText(time);
            mViewVideo.pageNum.setVisibility(View.VISIBLE);
        } catch (Exception e) {
            mViewVideo.pageNum.setVisibility(View.GONE);
        }
        setIntro(mViewVideo.intro, mItem, StringUtil.htmlDecoder(mItem.getSummary()), mContext.getResources().getString(R.string.post_video));
        setOrgin(mViewVideo, mItem);
        setBottom(mViewVideo, mItem);
        setHeadTuijian(mViewVideo, mItem);
        processTagData(mViewVideo, mItem, 0);
        OnClick groundOnClick = new OnClick(position);
        mViewVideo.head.setOnClickListener(groundOnClick);
        mViewVideo.work_header.setOnClickListener(groundOnClick);
        mViewVideo.name.setOnClickListener(groundOnClick);
        mViewVideo.recommendLayout.setOnClickListener(groundOnClick);
        mViewVideo.content.setOnClickListener(groundOnClick);
        mViewVideo.likeLayout.setOnClickListener(groundOnClick);
        mViewVideo.commentLayout.setOnClickListener(groundOnClick);
        mViewVideo.title.setOnClickListener(groundOnClick);
        mViewVideo.intro.setOnClickListener(groundOnClick);
        mViewVideo.viewFocuseCircle.setOnClickListener(groundOnClick);
    }

    private void setArticle(ViewArticle mViewArticle, Timeline mItem, int position) {
        ImageLoader.getInstance().displayImage(mItem.getContentAddress(), mViewArticle.content, ImageOptions.optionsTimeline, null, null, false);
        mViewArticle.pageNum.setVisibility(View.GONE);
        if (!TextUtils.isEmpty(mItem.getTitle())) {
            mViewArticle.title.setVisibility(View.VISIBLE);
            mViewArticle.title.setText(Html.fromHtml(mItem.getTitle()));
        } else {
            mViewArticle.title.setVisibility(View.GONE);
        }
        if (!TextUtils.isEmpty(mItem.getOUName())) {
            mViewArticle.author.setVisibility(View.VISIBLE);
            mViewArticle.author.setText(mItem.getOUName());
        } else {
            mViewArticle.author.setVisibility(View.GONE);
        }
        if (!TextUtils.isEmpty(mItem.getSummary())) {
            mViewArticle.summary.setText(StringUtil.htmlDecoder(mItem.getSummary()));
        } else {
            mViewArticle.summary.setText(mContext.getString(R.string.post_article));
        }
        setOrgin(mViewArticle, mItem);
        setBottom(mViewArticle, mItem);
        setHeadTuijian(mViewArticle, mItem);
        processTagData(mViewArticle, mItem, 0);
        OnClick groundOnClick = new OnClick(position);
        mViewArticle.head.setOnClickListener(groundOnClick);
        mViewArticle.work_header.setOnClickListener(groundOnClick);
        mViewArticle.name.setOnClickListener(groundOnClick);
        mViewArticle.recommendLayout.setOnClickListener(groundOnClick);
        mViewArticle.content.setOnClickListener(groundOnClick);
        mViewArticle.likeLayout.setOnClickListener(groundOnClick);
        mViewArticle.commentLayout.setOnClickListener(groundOnClick);
        ((View) (mViewArticle.title.getParent())).setOnClickListener(groundOnClick);
        mViewArticle.summary.setOnClickListener(groundOnClick);
        mViewArticle.viewFocuseCircle.setOnClickListener(groundOnClick);
    }

    private void setGoods(ViewGoods viewGoods, Timeline mItem, int postion) {
        ImageLoader.getInstance().displayImage(mItem.getContentAddress(), viewGoods.content, ImageOptions.optionsDetail);
        if (!TextUtils.isEmpty(mItem.getTitle())) {
            ((View) (viewGoods.goodsName.getParent())).setVisibility(View.VISIBLE);
            viewGoods.goodsName.setText(Html.fromHtml(mItem.getTitle()).toString());
        } else {
            ((View) (viewGoods.goodsName.getParent())).setVisibility(View.GONE);
        }
        setIntro(viewGoods.intro, mItem, mItem.getIntro(), mContext.getResources().getString(R.string.post_goods));
        if (!TextUtils.isEmpty(mItem.getPrice())) {
            viewGoods.price.setText(String.format(mContext.getString(R.string.price_format), CurrencyUtil.getMoney(mItem.getPrice())));
        }
        viewGoods.tags.setVisibility(View.GONE);
        setOrgin(viewGoods, mItem);
        setBottom(viewGoods, mItem);
        setHeadTuijian(viewGoods, mItem);
        OnClick groundOnClick = new OnClick(postion);
        viewGoods.head.setOnClickListener(groundOnClick);
        viewGoods.work_header.setOnClickListener(groundOnClick);
        viewGoods.name.setOnClickListener(groundOnClick);
        viewGoods.recommendLayout.setOnClickListener(groundOnClick);
        ((View) (viewGoods.content.getParent())).setOnClickListener(groundOnClick);
        viewGoods.likeLayout.setOnClickListener(groundOnClick);
        viewGoods.buyLayout.setOnClickListener(groundOnClick);
        viewGoods.intro.setOnClickListener(groundOnClick);
        viewGoods.viewFocuseCircle.setOnClickListener(groundOnClick);
    }

    private void setEmpty(ViewEmpty viewEmpty) {
        viewEmpty.viewGotoHotWorks.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                gotoUtil.gotoAct(mContext, DiscoverCircleActivity.class, DiscoverCircleActivity.TYPE_WORK);
            }
        });

        RecyclerView.LayoutParams layoutParams = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        viewEmpty.itemView.setLayoutParams(layoutParams);
    }

    private void setCircle(final ViewCircle viewCircle, final Timeline mItem, int position) {
        if (null == mItem.getTimelineCircles()) return;
        List<TimelineCircle> circles = mItem.getTimelineCircles();
        viewCircle.viewGoMoreCircle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                gotoUtil.gotoAct(mContext, DiscoverCircleActivity.class, DiscoverCircleActivity.TYPE_WORK);
            }
        });
        for (int i = 0; i < viewCircle.circle_container.getChildCount(); i++) {
            if (i < circles.size()) {
                viewCircle.circleCards[i].itemView.setVisibility(View.VISIBLE);
                processCircleType(mItem, viewCircle.circleCards[i], circles.get(i), position);
            } else {
                viewCircle.circleCards[i].itemView.setVisibility(View.INVISIBLE);
            }
        }
    }

    private void processCircleType(final Timeline mItem, final ViewCircle.CircleCard circleCard, final TimelineCircle circle, final int position) {
        ImageLoader.getInstance().displayImage(circle.getCover(), circleCard.ivCirclePic, ImageOptions.optionsTimeline, null, null, true);
        circleCard.tvCircleName.setText(circle.getReal_name());
        if ("true".equals(circle.getWf_status())) {
            circleCard.tvCircleSubscribed.setVisibility(View.VISIBLE);
            circleCard.tvCircleSubscribe.setVisibility(View.GONE);
        } else {
            circleCard.tvCircleSubscribed.setVisibility(View.GONE);
            circleCard.tvCircleSubscribe.setVisibility(View.VISIBLE);
        }

        circleCard.viewCircleDelete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                alertDelete(mItem, circle, position);
            }
        });

        circleCard.tvCircleSubscribe.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if ("false".equals(circle.getWf_status()))
                    CircleLikeHelper.doCircleLike(mContext, circle.getWid(), "work", "follow", new CircleLikeHelper.CircleLikeSuccess() {
                        @Override
                        public void onCircleLikeSuccess() {
                            circleCard.tvCircleSubscribed.setVisibility(View.VISIBLE);
                            circleCard.tvCircleSubscribe.setVisibility(View.GONE);
                            circle.setWf_status("true");
                        }
                    });
            }
        });
        circleCard.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext, CircleSmoothActivity.class);
                intent.putExtra(gotoUtil.INTENT_VALUE_TWO, circle.getWid());
                intent.putExtra(gotoUtil.INTENT_VALUE_ONE, circle.getReal_name());
                mContext.startActivity(intent);
            }
        });
    }

    private void doCircleBan(final Timeline mItem, final TimelineCircle cirlce, final int position) {
        BanTimeLineHelper banTimeLineHelper = new BanTimeLineHelper(new BanTimeLineInter() {
            @Override
            public void succ(String s) {
                mItem.getTimelineCircles().remove(cirlce);
                notifyItemChanged(position);
                if (mItem.getTimelineCircles().size() == 0) {
                    notifyItemRemoved(position);
                    tlist.remove(mItem);
                    notifyItemRangeChanged(0, getItemCount());
                }
            }

            @Override
            public void fail() {
            }
        }, mContext);
        banTimeLineHelper.doBanWork(cirlce.getWid());
    }

    private void alertDelete(final Timeline mItem, final TimelineCircle circle, final int position) {
        ConfirmDialog.Builder builder = new ConfirmDialog.Builder(mContext);
        builder.setDescString(mContext.getString(R.string.ban_work_alert))
                .setActionString(mContext.getString(R.string.mydialog_comfirm))
                .setCancelString(mContext.getString(R.string.mydialog_cancel))
                .setActionClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        doCircleBan(mItem, circle, position);
                    }
                })
                .create().show();

    }


    private void setOrgin(BaseView baseView, Timeline mItem) {
        DisplayMetrics dm = new DisplayMetrics();
        WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
        wm.getDefaultDisplay().getMetrics(dm);
        int width = dm.widthPixels;
        baseView.viewFocuseCircle.setVisibility(View.GONE);
        if (StringUtil.notNullEqual(mItem.getTl_type(), "work") || StringUtil.notNullEqual(mItem.getTl_type(), "tag")
                || StringUtil.notNullEqual(mItem.getTl_type(), "site_work") || StringUtil.notNullEqual(mItem.getTl_type(), "site_tag")) {
            baseView.work_header.setVisibility(View.VISIBLE);
            baseView.head.setVisibility(View.GONE);

            if (StringUtil.notNullEqual(mItem.getTl_type(), "work") || StringUtil.notNullEqual(mItem.getTl_type(), "site_work")) {
                baseView.name.setText(mItem.getRealName());
                ImageLoader.getInstance().displayImage(mItem.getWork_cover(), baseView.work_header, ImageOptions.optionHead);
                if (StringUtil.notNullEqual(mItem.getTl_type(), "site_work")) {
                    if (StringUtil.notNullEqual(mItem.getWf_status(), "false")) {
                        baseView.viewFocuseCircle.setVisibility(View.VISIBLE);
                        setNameWidth(width, baseView, 150);
                    } else {
                        setNameWidth(width, baseView, 180);
                    }
                } else {
                    setNameWidth(width, baseView, 180);

                }
            } else {
                baseView.name.setText(mItem.getTag_name());
                ImageLoader.getInstance().displayImage(mItem.getTag_cover(), baseView.work_header, ImageOptions.optionHead);
                if (StringUtil.notNullEqual(mItem.getTl_type(), "site_tag")) {
                    if (StringUtil.notNullEqual(mItem.getTf_status(), "false")) {
                        baseView.viewFocuseCircle.setVisibility(View.VISIBLE);
                        setNameWidth(width, baseView, 150);
                    } else {
                        setNameWidth(width, baseView, 180);
                    }
                } else {
                    setNameWidth(width, baseView, 180);

                }
            }
        } else if (StringUtil.notNullEqual(mItem.getTl_type(), "group")) {
            baseView.name.setText(mContext.getString(R.string.mine_topic));
            baseView.head.setVisibility(View.GONE);
            baseView.work_header.setVisibility(View.VISIBLE);
            baseView.work_header.setImageResource(R.drawable.rela_topic_default);
            setNameWidth(width, baseView, 240);

        } else {
            baseView.name.setText(mItem.getUName());
            baseView.work_header.setVisibility(View.GONE);
            baseView.head.setVisibility(View.VISIBLE);
            ImageLoader.getInstance().displayImage(mItem.getHeadAddress(), baseView.head, ImageOptions.optionHead);
            setNameWidth(width, baseView, 240);
        }
    }

    private void setNameWidth(int width, BaseView baseView, int max) {
        if (width >= 1080) {
            baseView.name.setMaxWidth(UIUtils.dip2px(max, mContext));
        } else {
            baseView.name.setMaxWidth(UIUtils.dip2px(max - 40, mContext));
        }
    }


    private void setIntro(EllipsezeTextView tvIntro, Timeline mItem, String intro, String defaultIntro) {
        if (TextUtils.isEmpty(mItem.getTl_type()) || StringUtil.notNullEqual(mItem.getTl_type(), "user")) {
            if (StringUtil.notNullEqual(mItem.getUid(), mItem.getOuid()) || TextUtils.isEmpty(mItem.getUid())) {
                setCommonIntro(tvIntro, intro);
            } else {
                setRecommendIntro(tvIntro, mItem, intro, defaultIntro);
            }
        } else if ("site_tag".equals(mItem.getTl_type()) || "site_work".equals(mItem.getTl_type()) || "work".equals(mItem.getTl_type()) || "tag".equals(mItem.getTl_type()) || "group".equals(mItem.getTl_type())) {
            setRecommendIntro(tvIntro, mItem, intro, defaultIntro);
        } else {
            setCommonIntro(tvIntro, intro);
        }
    }

    private void setCommonIntro(EllipsezeTextView tvIntro, String intro) {
        if (TextUtils.isEmpty(intro)) {
            tvIntro.setVisibility(View.GONE);
        } else {
            tvIntro.setVisibility(View.VISIBLE);
            tvIntro.setText(intro, "", "", false);
        }
    }

    private void setRecommendIntro(EllipsezeTextView tvIntro, Timeline mItem, String intro, String defaultIntro) {
        String finalIntro = TextUtils.isEmpty(intro) ? defaultIntro : intro;
        finalIntro = String.format(mContext.getResources().getString(R.string.card_recommended_user_format), mItem.getOUName(), finalIntro);
        tvIntro.setText(finalIntro, mItem.getOUName(), mItem.getOuid(), true);
        tvIntro.setVisibility(View.VISIBLE);
    }

    private void setHeadTuijian(BaseView baseView, final Timeline mItem) {
        baseView.time.setVisibility(View.VISIBLE);
        baseView.viewFeedsContainer.setVisibility(View.INVISIBLE);
        baseView.tvFeedInfo.setVisibility(View.GONE);
        if (TextUtils.isEmpty(mItem.getTl_type())) {
            baseView.circle_label.setVisibility(View.GONE);
            if (StringUtil.notNullEqual(mItem.getUid(), mItem.getOuid()) || TextUtils.isEmpty(mItem.getUid())) {
                baseView.tuijian_label.setVisibility(View.GONE);
            } else {
                baseView.tuijian_label.setVisibility(View.VISIBLE);
                baseView.tuijian_label.setText(mContext.getString(R.string.has_recommend_short));
            }
        } else {
            if (StringUtil.notNullEqual(mItem.getTl_type(), "user")) {
                baseView.circle_label.setVisibility(View.GONE);
                if (StringUtil.notNullEqual(mItem.getUid(), mItem.getOuid()) || TextUtils.isEmpty(mItem.getUid())) {
                    baseView.tuijian_label.setVisibility(View.GONE);
                } else {
                    baseView.tuijian_label.setVisibility(View.VISIBLE);
                    baseView.tuijian_label.setText(mContext.getString(R.string.has_recommend_short));
                }
            } else if (StringUtil.notNullEqual(mItem.getTl_type(), "toppay")) {
                baseView.tvFeedInfo.setVisibility(View.VISIBLE);
                baseView.viewFeedsContainer.setVisibility(View.VISIBLE);
                baseView.time.setVisibility(View.GONE);
                baseView.tuijian_label.setVisibility(View.GONE);
                baseView.circle_label.setVisibility(View.GONE);
                if ("1".equals(mItem.getPays())) {
                    baseView.tvFeedInfo.setText(Html.fromHtml(String.format(mContext.getString(R.string.feedformat), mItem.getFrom_uname())));
                } else {
                    baseView.tvFeedInfo.setText(Html.fromHtml(String.format(mContext.getString(R.string.feedmoreformat), mItem.getFrom_uname(), mItem.getPays())));
                }
                baseView.tvFeedInfo.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        gotoUtil.gotoAct(mContext, SmoothPersonActivity.class, mItem.getFrom_uid());
                    }
                });
            } else if (StringUtil.notNullEqual(mItem.getTl_type(), "group")) {
                baseView.circle_label.setVisibility(View.GONE);
                baseView.tuijian_label.setVisibility(View.VISIBLE);
                baseView.tuijian_label.setText(mContext.getString(R.string.has_recommend_short));
            } else if (StringUtil.notNullEqual(mItem.getTl_type(), "site_work") || StringUtil.notNullEqual(mItem.getTl_type(), "site_tag")) {
                baseView.circle_label.setVisibility(View.VISIBLE);
                baseView.tuijian_label.setVisibility(View.VISIBLE);
                baseView.tuijian_label.setText(mContext.getString(R.string.from_your_interest));
            } else {
                baseView.circle_label.setVisibility(View.VISIBLE);
                baseView.tuijian_label.setVisibility(View.VISIBLE);
                baseView.tuijian_label.setText(mContext.getString(R.string.has_recommend_short));
            }
        }
        int type = TimelineFactory.whichType(mItem);
        baseView.time.setText(StringUtil.getOppositeTime(mItem.getPushtime()));
        setTimelineContral(baseView, mItem, type);
        setContral(baseView, mItem);
    }

    private void setTimelineContral(BaseView baseView, Timeline mItem, int type) {
        if (StringUtil.notNullEqual(mItem.getTl_type(), "user")) {
            if (StringUtil.notNullEqual(UserDataHelper.getInstance(mContext).getUid(), mItem.getOuid())) {
                baseView.timeline_contral.setVisibility(View.GONE);
            } else {
                if (type == TimelineFactory.TIMELINE_TYPE_ASK) {
                    baseView.timeline_contral.setVisibility(View.GONE);
                } else {
                    baseView.timeline_contral.setVisibility(View.VISIBLE);
                }
            }
        } else {
            if (StringUtil.notNullEqual(UserDataHelper.getInstance(mContext).getUid(), mItem.getUid())) {
                baseView.timeline_contral.setVisibility(View.GONE);
            } else {
                if (type == TimelineFactory.TIMELINE_TYPE_ASK) {
                    baseView.timeline_contral.setVisibility(View.GONE);
                } else {
                    baseView.timeline_contral.setVisibility(View.VISIBLE);
                }
            }
        }
    }

    private void setContral(final BaseView baseView, final Timeline mItem) {
        baseView.timeline_contral.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showBanDiagLog(mItem, "card", baseView.itemView.getTop() + UIUtils.dip2px(40, mContext));
            }
        });
    }

    private void setSpotContral(final ViewSpot mViewSpot, final Timeline mItem) {
        mViewSpot.control_iv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showBanDiagLog(mItem, "spot", mViewSpot.itemView.getTop() + UIUtils.dip2px(40, mContext));
            }
        });
    }

    private void showBanDiagLog(final Timeline mItem, final String type, int top) {

        TimelineBanDialog.Builder builder = new TimelineBanDialog.Builder(mContext);
        builder.setType(type).setBanTimelineTypeText(formatTimelineType(mItem))
                .setBanContentListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        doBanContent(mItem, type);
                    }
                }).setBanAndReportContentListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                gotoReport(mItem);
            }
        }).setBanTimelineTypeListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                banTimelineType();
            }
        }).setTop(top).create().show();
    }

    private String formatTimelineType(Timeline mItem) {
        switch (TimelineFactory.whichType(mItem)) {
            case TimelineFactory.TIMELINE_TYPE_COSER:
                return String.format(mContext.getString(R.string.ban_timeline_type), mContext.getString(R.string.cos));
            case TimelineFactory.TIMELINE_TYPE_ILLUST:
                return String.format(mContext.getString(R.string.ban_timeline_type), mContext.getString(R.string.draw));
            case TimelineFactory.TIMELINE_TYPE_WRITER:
                return String.format(mContext.getString(R.string.ban_timeline_type), mContext.getString(R.string.write));
            case TimelineFactory.TIMELINE_TYPE_DAILY:
                return String.format(mContext.getString(R.string.ban_timeline_type), mContext.getString(R.string.daily));
            case TimelineFactory.TIMELINE_TYPE_GOODS:
                return String.format(mContext.getString(R.string.ban_timeline_type), mContext.getString(R.string.goods));
            case TimelineFactory.TIMELINE_TYPE_GROUP:
            case TimelineFactory.TIMELINE_TYPE_GROUP_TEAM:
                return String.format(mContext.getString(R.string.ban_timeline_type), mContext.getString(R.string.topic));
        }
        return "";
    }

    private void setBan(ViewMoreBan viewMoreBan, final Timeline mItem, final int position) {
        if (!ban_list.contains(mItem.getBan_key())) {
            viewMoreBan.banContainer.setVisibility(View.VISIBLE);
            ban_list.add(mItem.getBan_key());
            viewMoreBan.tags.removeAllViews();
            int count = 0;
            final List<TagDetail> templist = mItem.getTags();
            if (templist != null && !templist.isEmpty()) {
                viewMoreBan.tags.setVisibility(View.VISIBLE);
                viewMoreBan.tags.setHorizontalSpacing(UIUtils.dip2px(8, mContext));
                viewMoreBan.tags.setVerticalSpacing(UIUtils.dip2px(8, mContext));
                for (final TagDetail t : templist) {
                    if (!TextUtils.isEmpty(t.getWork()) && TextUtils.isEmpty(t.getWid())) {
                        continue;
                    }
                    TextView tv = (TextView) View.inflate(mContext, R.layout.timeline_ban_tag_item, null);
                    if (!TextUtils.isEmpty(t.getTag_name())) {
                        tv.setText(t.getTag_name());
                    }
                    tv.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            if (TextUtils.isEmpty(t.getWid())) {
                                setBlock(t.getTag_id(), v, "tag");
                            } else {
                                setBlock(t.getWid(), v, "work");
                            }
                        }
                    });
                    viewMoreBan.tags.addView(tv);
                }
            } else {
                count++;
            }
            if (!TextUtils.isEmpty(mItem.getOUName())) {
                TextView tv = (TextView) View.inflate(mContext, R.layout.timeline_ban_tag_item, null);
                tv.setText(String.format(mContext.getString(R.string.who_post), mItem.getOUName()));
                tv.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        setBlock(mItem.getOuid(), v, "user");
                    }
                });
                viewMoreBan.tags.addView(tv);
            } else {
                count++;
            }
            if (count == 2) {
                viewMoreBan.tags.setVisibility(View.GONE);
            } else {
                viewMoreBan.tags.setVisibility(View.VISIBLE);
            }
            viewMoreBan.comfirm.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    notifyItemRemoved(position + 1);
                    tlist.remove(mItem);
                    notifyItemRangeChanged(0, getItemCount());
                }
            });
        } else {
            viewMoreBan.banContainer.setVisibility(View.GONE);
            viewMoreBan.banContainer.post(new Runnable() {
                @Override
                public void run() {
                    notifyItemRemoved(position + 1);
                    tlist.remove(mItem);
                    notifyItemRangeChanged(0, getItemCount());
                }
            });
        }
    }

    private void setBlock(String id, final View v, String type) {
        if (v.isSelected()) {
            delBlock(id, type, new SimpleBlockImpl() {
                @Override
                public void getSucc(String json) {
                    try {
                        JSONObject jsonObject = new JSONObject(json);
                        MyToast.show(mContext, jsonObject.getString(HttpUtils.UPLOAD_DATA));
                        v.setSelected(!v.isSelected());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        } else {
            addBlock(id, type, new SimpleBlockImpl() {
                @Override
                public void getSucc(String json) {
                    try {
                        JSONObject jsonObject = new JSONObject(json);
                        MyToast.show(mContext, jsonObject.getString(HttpUtils.UPLOAD_DATA));
                        v.setSelected(!v.isSelected());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        }
    }

    private void addBlock(String id, String type, IBlockHelper iBlockHelper) {
        BlockHelper blockHelper = new BlockHelper(iBlockHelper, mContext);
        if (type.equals("user")) {
            blockHelper.doBlock(UserDataHelper.getInstance(mContext).getToken(), id);
        } else {
            blockHelper.addBlockCircle(UserDataHelper.getInstance(mContext).getToken(), id, type);
        }
    }

    private void delBlock(String id, String type, IBlockHelper iBlockHelper) {
        BlockHelper blockHelper = new BlockHelper(iBlockHelper, mContext);
        if (type.equals("user")) {
            blockHelper.unBlock(UserDataHelper.getInstance(mContext).getToken(), id);
        } else {
            blockHelper.delBlockCircle(UserDataHelper.getInstance(mContext).getToken(), id, type);
        }
    }

    private void banTimelineType() {
        gotoUtil.gotoAct(mContext, MainSettingActivity.class);
    }

    private void gotoReport(Timeline mItem) {
        Intent intent;
        switch (TimelineFactory.whichType(mItem)) {
            case TimelineFactory.TIMELINE_TYPE_GROUP_TEAM:
                intent = new Intent(mContext, ReportActivity.class);
                intent.putExtra(gotoUtil.INTENT_VALUE_ONE, 2);
                intent.putExtra(gotoUtil.INTENT_VALUE_THREE, mItem.getGid());
                intent.putExtra(MyConstants.TIMELINETYPE, TimelineFactory.whichType(mItem));
                intent.putExtra(gotoUtil.INTENT_VALUE_FIVE, tlist.indexOf(mItem));
                mContext.startActivity(intent);
                break;
            case TimelineFactory.TIMELINE_TYPE_COSER:
            case TimelineFactory.TIMELINE_TYPE_ILLUST:
            case TimelineFactory.TIMELINE_TYPE_WRITER:
            case TimelineFactory.TIMELINE_TYPE_DAILY:
            case TimelineFactory.TIMELINE_TYPE_GROUP:
            case TimelineFactory.TIMELINE_TYPE_GOODS:
                intent = new Intent(mContext, ReportActivity.class);
                intent.putExtra(MyConstants.TIMELINETYPE, TimelineFactory.whichType(mItem));
                mItem.setTimelineType(TimelineFactory.whichType(mItem));
                DetailDataHelper.putBaseDetailValue(intent, mItem);
                intent.putExtra(gotoUtil.INTENT_VALUE_FIVE, tlist.indexOf(mItem));
                mContext.startActivity(intent);
                break;
            default:
                MyToast.show(mContext, mContext.getString(R.string.report_up_succ));
                break;
        }
    }

    public void doBanContent(final Timeline mItem, final String type) {
        BanTimeLineInter banTimeLineInter = new BanTimeLineInter() {
            @Override
            public void succ(String s) {
                if (StatusCodeUtils.dealStatusCode(s, mContext)) {
                    if (!type.equals("spot")) {
                        mItem.setOtype_data(MyConstants.OTYPE_MORE_BAN);
                        mItem.setOtype(MyConstants.OTYPE_MORE_BAN);
                        mItem.setBan_key(String.valueOf(System.currentTimeMillis()));
                        notifyItemChanged(tlist.indexOf(mItem) + 1);
                    } else {
                        notifyItemRemoved(tlist.indexOf(mItem) + 1);
                        tlist.remove(mItem);
                        notifyItemRangeChanged(0, getItemCount());
                    }
                }
            }

            @Override
            public void fail() {
                MyToast.show(mContext, mContext.getString(R.string.operation_fail));
            }
        };
        BanTimeLineHelper banTimeLineHelper = new BanTimeLineHelper(banTimeLineInter, mContext);
        if (!type.equals("spot")) {
            banTimeLineHelper.doBan(mItem);
        } else {
            banTimeLineHelper.doBanSpot(mItem);
        }
    }

    public void doBanContent(final int index, String type) {
        if (index < tlist.size() && index >= 0)
            doBanContent(tlist.get(index), type);
    }

    private void setBottom(BaseView baseView, final Timeline mItem) {
        if (!TextUtils.isEmpty(mItem.getCommentNum()) && baseView.commentNum != null) {
            if (Integer.parseInt(mItem.getCommentNum()) > 0) {
                baseView.commentNum.setText(mItem.getCommentNum());
            } else {
                baseView.commentNum.setText(mContext.getString(R.string.comment));
            }
        }
        if (StringUtil.getHaveDingBoolean(mItem)) {
            baseView.likeNumImg.setImageResource(R.drawable.like_pink);
            baseView.likeNum.setText(mItem.getLikeNum());
        } else {
            baseView.likeNumImg.setImageResource(R.drawable.like_grey);
            baseView.likeNum.setText(mItem.getLikeNum());
            if (mItem.getLikeNum().equals("0")) {
                baseView.likeNum.setText(mContext.getString(R.string.good));
            }
        }
        if (StringUtil.notNullEqual(mItem.getHaveRecommend(), "true")) {
            baseView.recommend.setText(mContext.getString(R.string.all_recommended));
        } else {
            baseView.recommend.setText(mContext.getString(R.string.all_recommend));
        }
    }

    private void setCosIllust(ViewHolder mViewHolder, Timeline mItem, int postion) {
        ImageLoader.getInstance().displayImage(mItem.getContentAddress(), mViewHolder.content, ImageOptions.optionsTimeline, null, null, true);
        if (!TextUtils.isEmpty(mItem.getPicNum())) {
            if (Integer.parseInt(mItem.getPicNum()) > 1) {
                mViewHolder.pageNum.setVisibility(View.VISIBLE);
            } else {
                mViewHolder.pageNum.setVisibility(View.GONE);
            }
        }
        String defaultIntro = TimelineFactory.whichType(mItem) == TimelineFactory.TIMELINE_TYPE_COSER ? mContext.getString(R.string.post_cos) : mContext.getString(R.string.post_draw);
        setIntro(mViewHolder.intro, mItem, mItem.getIntro(), defaultIntro);
        setOrgin(mViewHolder, mItem);
        setBottom(mViewHolder, mItem);
        setHeadTuijian(mViewHolder, mItem);
        processTagData(mViewHolder, mItem, 0);
        OnClick groundOnClick = new OnClick(postion);
        mViewHolder.head.setOnClickListener(groundOnClick);
        mViewHolder.work_header.setOnClickListener(groundOnClick);
        mViewHolder.name.setOnClickListener(groundOnClick);
        mViewHolder.recommendLayout.setOnClickListener(groundOnClick);
        mViewHolder.content.setOnClickListener(groundOnClick);
        mViewHolder.likeLayout.setOnClickListener(groundOnClick);
        mViewHolder.commentLayout.setOnClickListener(groundOnClick);
        mViewHolder.intro.setOnClickListener(groundOnClick);
        mViewHolder.viewFocuseCircle.setOnClickListener(groundOnClick);
    }

    private void setDaily(ViewDaily mViewDaily, Timeline mItem, int postion) {
        if (!TextUtils.isEmpty(mItem.getContentAddress())) {
            String[] addressList = mItem.getContentAddress().split(" ");
            int dailyLength = addressList.length;
            if (dailyLength == 0) {
                mViewDaily.imagePics.setVisibility(View.GONE);
            } else {
                mViewDaily.imagePics.setVisibility(View.VISIBLE);
                for (int i = 0; i < mViewDaily.content.length; i++) {
                    LinearLayout.LayoutParams ll = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT);
                    if (dailyLength == 1) {
                        ll.weight = 2 - i;
                    } else {
                        ll.weight = 1;
                        if (i < dailyLength - 1) {
                            ll.rightMargin = UIUtils.dip2px(4, mContext);
                        } else {
                            ll.rightMargin = 0;
                        }
                    }
                    mViewDaily.content[i].setLayoutParams(ll);
                    if (i < dailyLength) {
                        mViewDaily.content[i].setVisibility(View.VISIBLE);
                        ImageLoader.getInstance().displayImage(addressList[i], mViewDaily.content[i], ImageOptions.options);
                    } else {
                        if (dailyLength == 1) {
                            mViewDaily.content[i].setVisibility(View.INVISIBLE);
                        } else {
                            mViewDaily.content[i].setVisibility(View.GONE);
                        }
                    }
                }
            }
        } else {
            mViewDaily.imagePics.setVisibility(View.GONE);
        }
        String pic_num = mItem.getPic_num();
        if (!TextUtils.isEmpty(pic_num)) {
            if (Integer.parseInt(pic_num) > 3) {
                mViewDaily.pagenum.setVisibility(View.VISIBLE);
            } else {
                mViewDaily.pagenum.setVisibility(View.GONE);
            }
        } else {
            mViewDaily.pagenum.setVisibility(View.GONE);
        }
        setIntro(mViewDaily.intro, mItem, mItem.getIntro(), mContext.getString(R.string.write_name));
        setOrgin(mViewDaily, mItem);
        setBottom(mViewDaily, mItem);
        setHeadTuijian(mViewDaily, mItem);
        if (TimelineFactory.whichType(mItem) == TimelineFactory.TIMELINE_TYPE_DAILY) {
            processTagData(mViewDaily, mItem, 0);
        } else {
            mViewDaily.tags.setVisibility(View.GONE);
        }
        OnClick dailyOnClick = new OnClick(postion);
        mViewDaily.head.setOnClickListener(dailyOnClick);
        mViewDaily.work_header.setOnClickListener(dailyOnClick);
        mViewDaily.name.setOnClickListener(dailyOnClick);
        mViewDaily.intro.setOnClickListener(dailyOnClick);
        mViewDaily.recommendLayout.setOnClickListener(dailyOnClick);
        mViewDaily.likeLayout.setOnClickListener(dailyOnClick);
        mViewDaily.commentLayout.setOnClickListener(dailyOnClick);
        mViewDaily.imagePics.setOnClickListener(dailyOnClick);
        mViewDaily.teamNameLayout.setOnClickListener(dailyOnClick);
        mViewDaily.viewFocuseCircle.setOnClickListener(dailyOnClick);
    }

    private void setAsk(ViewAsk mViewAsk, Timeline mItem, int postion) {
        setOrgin(mViewAsk, mItem);
        setBottom(mViewAsk, mItem);
        setHeadTuijian(mViewAsk, mItem);
        Detail detail = mItem.getDetail();
        if (null != detail) {
            String cavatar = detail.getCavatar();
            doAskHeadPic(detail, mViewAsk.answerHead, cavatar);
        }
        if (TextUtils.isEmpty(mItem.getTl_type()) || StringUtil.notNullEqual(mItem.getTl_type(), "user")) {
            if (StringUtil.notNullEqual(mItem.getUid(), mItem.getOuid()) || TextUtils.isEmpty(mItem.getUid())) {
                mViewAsk.answer.setText(mItem.getContentAddress());
            } else {
                setRecommendAnswer(mViewAsk, mItem);
            }
        } else {
            mViewAsk.answer.setText(mItem.getContentAddress());
        }
        if (StringUtil.notNullEqual("0", mItem.getDp_id())) {
            mViewAsk.ask.setText(mItem.getIntro());
        } else {
            mViewAsk.ask.setText(mItem.getIntro());
        }
        OnClick askOnClick = new OnClick(postion);
        mViewAsk.head.setOnClickListener(askOnClick);
        mViewAsk.name.setOnClickListener(askOnClick);
        mViewAsk.recommendLayout.setOnClickListener(askOnClick);
        mViewAsk.likeLayout.setOnClickListener(askOnClick);
        mViewAsk.commentLayout.setOnClickListener(askOnClick);
        mViewAsk.answerHead.setOnClickListener(askOnClick);
        mViewAsk.container.setOnClickListener(askOnClick);
        mViewAsk.answer.setOnClickListener(askOnClick);

    }

    private void setRecommendAnswer(ViewAsk mViewAsk, Timeline mItem) {
        String answer = mItem.getContentAddress();
        answer = String.format(mContext.getResources().getString(R.string.card_recommended_user_format), mItem.getOUName(), answer);
        SpannableString sps = new SpannableString(answer);
        NoLineClickSpan no = new NoLineClickSpan(mItem.getOuid(), mContext, R.color.blue);
        sps.setSpan(no, 0, mItem.getOUName().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        mViewAsk.answer.setText(sps);
        mViewAsk.answer.setMovementMethod(LinkMovementMethod.getInstance());
    }

    private void setWriter(ViewWriter mViewWriter, Timeline mItem, int postion) {
        ImageLoader.getInstance().displayImage(mItem.getContentAddress(), mViewWriter.content, ImageOptions.options, null, null, true);
        setOrgin(mViewWriter, mItem);
        setBottom(mViewWriter, mItem);
        setHeadTuijian(mViewWriter, mItem);
        processTagData(mViewWriter, mItem, 0);
        mViewWriter.tvWriterDesc.setText(Html.fromHtml(mItem.getTitle()));
        setIntro(mViewWriter.intro, mItem, mItem.getIntro(), mContext.getString(R.string.post_write));
        if (!TextUtils.isEmpty(mItem.getSummary())) {
            mViewWriter.summery.setText(Html.fromHtml(mItem.getSummary()).toString().trim().replaceAll("(\\n)+", "\n"));
            mViewWriter.ellipsis.setText("......");
        }
        if ("true".equals(mItem.getPost_in_set())) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                mViewWriter.ivSeries.setImageDrawable(mContext.getResources().getDrawable(R.drawable.timeline_serise, mContext.getTheme()));
            } else {
                mViewWriter.ivSeries.setImageDrawable(mContext.getResources().getDrawable(R.drawable.timeline_serise));
            }
        } else {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                mViewWriter.ivSeries.setImageDrawable(mContext.getResources().getDrawable(R.drawable.timeline_single_write, mContext.getTheme()));
            } else {
                mViewWriter.ivSeries.setImageDrawable(mContext.getResources().getDrawable(R.drawable.timeline_single_write));
            }
        }
        OnClick writerOnClick = new OnClick(postion);
        mViewWriter.likeLayout.setOnClickListener(writerOnClick);
        mViewWriter.head.setOnClickListener(writerOnClick);
        mViewWriter.work_header.setOnClickListener(writerOnClick);
        mViewWriter.recommendLayout.setOnClickListener(writerOnClick);
        mViewWriter.content.setOnClickListener(writerOnClick);
        mViewWriter.commentLayout.setOnClickListener(writerOnClick);
        mViewWriter.name.setOnClickListener(writerOnClick);
        mViewWriter.intro.setOnClickListener(writerOnClick);
        mViewWriter.viewFocuseCircle.setOnClickListener(writerOnClick);
    }

    private void setAskMore(ViewAskMore mViewAskMore, Timeline mItem, int postion) {
        if (StringUtil.notNullStartWithUrlHead(mItem.getOavatar()))
            ImageLoader.getInstance().displayImage(mItem.getOavatar(),
                    mViewAskMore.head, ImageOptions.optionHead);
        else
            mViewAskMore.head.setImageResource(R.drawable.user_pic_big);
        mViewAskMore.name.setText(mItem.getOUName());
        mViewAskMore.time.setText(StringUtil.getOppositeTime(mItem.getPushtime()));
        List<Detail> details = mItem.getDetails();

        if (null != details && details.size() >= 3) {
            String asknum = details.get(0).getAsk();
            mViewAskMore.ask_more_nums.setText(String.format(mContext.getString(R.string.askmore), String.valueOf(details.size())));
            mViewAskMore.tvAskmoreAskone.setText(asknum);
            mViewAskMore.tvAskmoreAsktwo.setText(details.get(1).getAsk());
            mViewAskMore.tvAskmoreAskthree.setText(details.get(2).getAsk());

            mViewAskMore.tvAskmoreAnswerone.setText(details.get(0).getContentAddress());
            mViewAskMore.tvAskmoreAnswertwo.setText(details.get(1).getContentAddress());
            mViewAskMore.tvAskmoreAnswerthree.setText(details.get(2).getContentAddress());

            String firstHead = details.get(0).getCavatar();
            String secondHead = details.get(1).getCavatar();
            String thirdHead = details.get(2).getCavatar();
            doAskHeadPic(details.get(0), mViewAskMore.firstHead, firstHead);
            doAskHeadPic(details.get(1), mViewAskMore.secondHead, secondHead);
            doAskHeadPic(details.get(2), mViewAskMore.thirdHead, thirdHead);
        }

        OnClick askMoreOnClick = new OnClick(postion);
        mViewAskMore.head.setOnClickListener(askMoreOnClick);
        mViewAskMore.ll.setOnClickListener(askMoreOnClick);
        mViewAskMore.name.setOnClickListener(askMoreOnClick);
        mViewAskMore.firstHead.setOnClickListener(askMoreOnClick);
        mViewAskMore.secondHead.setOnClickListener(askMoreOnClick);
        mViewAskMore.thirdHead.setOnClickListener(askMoreOnClick);
    }

    private void doAskHeadPic(Detail detail, ImageView ivHead, String headUrl) {
        if ("1".equals(detail.getAnonymous())) {
            ivHead.setImageResource(R.drawable.user_pic_anonymous);
        } else {
            if (StringUtil.notNullStartWithUrlHead(headUrl)) {
                ImageLoader.getInstance().displayImage(headUrl, ivHead, ImageOptions.optionHead);
            } else {
                ivHead.setImageResource(R.drawable.user_pic_big);
            }
        }
    }

    private void setGroup(ViewGroupTeam mViewGroupTeam, Timeline mItem, int position) {
        setOrgin(mViewGroupTeam, mItem);
        setHeadTuijian(mViewGroupTeam, mItem);
        mViewGroupTeam.tvGroupTeamTitle.setText(Html.fromHtml(mItem.getGroupTitle()));
        if ("0".equals(mItem.getPost_num())) {
            mViewGroupTeam.tvGroupTeamJoin.setText(mContext.getString(R.string.post_message));
        } else {
            mViewGroupTeam.tvGroupTeamJoin.setText(String.format(mContext.getString(R.string.join_talk_card), mItem.getPost_num()));
        }
        if (TextUtils.isEmpty(mItem.getContentAddress())) {
            mViewGroupTeam.ivGroupCover.setVisibility(View.GONE);
        } else {
            mViewGroupTeam.ivGroupCover.setVisibility(View.VISIBLE);
            ImageLoader.getInstance().displayImage(mItem.getContentAddress(), mViewGroupTeam.ivGroupCover, ImageOptions.options);
        }
        if (TextUtils.isEmpty(mItem.getIntro())) {
            mViewGroupTeam.tvGroupTeamDesc.setVisibility(View.GONE);
        } else {
            mViewGroupTeam.tvGroupTeamDesc.setVisibility(View.VISIBLE);
            mViewGroupTeam.tvGroupTeamDesc.setText(Html.fromHtml(mItem.getIntro()));
        }
        OnClick viewGroupTeamOnClick = new OnClick(position);
        mViewGroupTeam.head.setOnClickListener(viewGroupTeamOnClick);
        mViewGroupTeam.work_header.setOnClickListener(viewGroupTeamOnClick);
        mViewGroupTeam.name.setOnClickListener(viewGroupTeamOnClick);
        mViewGroupTeam.viewBody.setOnClickListener(viewGroupTeamOnClick);
        mViewGroupTeam.viewFocuseCircle.setOnClickListener(viewGroupTeamOnClick);
    }

    private void setGroupPost(ViewPost mViewPost, Timeline mItem, int postion) {
        setOrgin(mViewPost, mItem);
        setBottom(mViewPost, mItem);
        setHeadTuijian(mViewPost, mItem);
        mViewPost.teamName.setText(StringUtil.htmlDecoder(mItem.getGname()));
        if (!TextUtils.isEmpty(mItem.getContentAddress())) {
            String[] addressList = mItem.getContentAddress().split(" ");
            if (addressList.length == 0) {
                mViewPost.imagePics.setVisibility(View.GONE);
            } else {
                mViewPost.imagePics.setVisibility(View.VISIBLE);
                for (int i = 0; i < mViewPost.content.length; i++) {
                    if (i < addressList.length) {
                        mViewPost.content[i].setVisibility(View.VISIBLE);
                        ImageLoader.getInstance().displayImage(addressList[i], mViewPost.content[i], ImageOptions.options);
                    } else {
                        mViewPost.content[i].setVisibility(View.INVISIBLE);
                    }
                }
            }
        } else {
            mViewPost.imagePics.setVisibility(View.GONE);
        }
        String pic_num = mItem.getPic_num();
        if (!TextUtils.isEmpty(pic_num)) {
            if (Integer.parseInt(pic_num) > 3) {
                mViewPost.pagenum.setVisibility(View.VISIBLE);
            } else {
                mViewPost.pagenum.setVisibility(View.GONE);
            }
        } else {
            mViewPost.pagenum.setVisibility(View.GONE);
        }
        setIntro(mViewPost.intro, mItem, mItem.getIntro(), mContext.getString(R.string.post_topic));
        if (TimelineFactory.whichType(mItem) == TimelineFactory.TIMELINE_TYPE_DAILY) {
            processTagData(mViewPost, mItem, 0);
        } else {
            mViewPost.tags.setVisibility(View.GONE);
        }
        OnClick dailyOnClick = new OnClick(postion);
        mViewPost.head.setOnClickListener(dailyOnClick);
        mViewPost.work_header.setOnClickListener(dailyOnClick);
        mViewPost.name.setOnClickListener(dailyOnClick);
        mViewPost.intro.setOnClickListener(dailyOnClick);
        mViewPost.recommendLayout.setOnClickListener(dailyOnClick);
        mViewPost.likeLayout.setOnClickListener(dailyOnClick);
        mViewPost.commentLayout.setOnClickListener(dailyOnClick);
        mViewPost.imagePics.setOnClickListener(dailyOnClick);
        mViewPost.teamNameLayout.setOnClickListener(dailyOnClick);
        mViewPost.viewFocuseCircle.setOnClickListener(dailyOnClick);
    }

    private void setSpot(final ViewSpot viewSpot, final Timeline mItem) {
        if (!TextUtils.isEmpty(mItem.getDetail().getBanner())) {
            viewSpot.head_iv.setVisibility(View.VISIBLE);
            ImageLoader.getInstance().displayImage(mItem.getDetail().getBanner(), viewSpot.head_iv, ImageOptions.optionsSpotPic);
        } else {
            viewSpot.head_iv.setVisibility(View.INVISIBLE);
        }
        if (!TextUtils.isEmpty(mItem.getDetail().getPlain())) {
            viewSpot.intro.setText(Html.fromHtml(mItem.getDetail().getPlain()));
        }
        TagDetail tagDetail = new TagDetail();
        if (!TextUtils.isEmpty(mItem.getEvent_id())) {
            tagDetail.setEvent_id(mItem.getEvent_id());
        }
        viewSpot.tag.setVisibility(View.VISIBLE);
        switch (TimelineFactory.whichType(mItem)) {
            case TimelineFactory.TIMELINE_TYPE_SPOT_TAG:
                viewSpot.title.setText(mItem.getTag_name());
                viewSpot.tag.setVisibility(View.VISIBLE);
                break;
            case TimelineFactory.TIMELINE_TYPE_SPOT_WORK:
                viewSpot.title.setText(mItem.getRealName());
                viewSpot.tag.setVisibility(View.VISIBLE);
                break;
            case TimelineFactory.TIMELINE_TYPE_SPOT_TEXT:
                viewSpot.tag.setVisibility(View.GONE);
                if (!TextUtils.isEmpty(mItem.getDetail().getPlain()))
                    viewSpot.title.setText(mItem.getDetail().getTitle());
                break;
        }

        if (!TextUtils.isEmpty(mItem.getDetail().getCode())) {
            viewSpot.spot_container.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    PushDataHelper.processInnerPushData(mContext, mItem.getDetail().getCode());
                }
            });
        }
        viewSpot.control_iv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                setSpotContral(viewSpot, mItem);
            }
        });
    }

    private void processTagData(BaseView baseView, final Timeline mItem, final int from) {
        if (mItem.getTags() != null && mItem.getTags().size() > 0) {
            baseView.tags.setTlist(mItem.getTags());
            baseView.tags.setVisibility(View.VISIBLE);
        } else {
            baseView.tags.setVisibility(View.GONE);
        }
        baseView.tags.setTagViewClick(new TagView.OnTagClickListener() {
            @Override
            public void onClick(TagDetail t) {
                if (!TextUtils.isEmpty(t.getWork())) {
                    if (!TextUtils.isEmpty(t.getWid())) {
                        Intent intent = new Intent(mContext, CircleSmoothActivity.class);
                        intent.putExtra(gotoUtil.INTENT_VALUE_ONE, t.getWork());
                        intent.putExtra(gotoUtil.INTENT_VALUE_TWO, t.getWid());
                        intent.putExtra("from", from);
                        mContext.startActivity(intent);
                    }
                } else if (!TextUtils.isEmpty(t.getEvent_id())) {
                    gotoUtil.gotoAct(mContext, EventDetailActivity.class, t.getEvent_id());
                } else {
                    Intent intent = new Intent(mContext, CircleTagSmoothActivity.class);
                    intent.putExtra(gotoUtil.INTENT_VALUE_ONE, t.getTag_name());
                    intent.putExtra("type", "tag");
                    intent.putExtra("from", from);
                    mContext.startActivity(intent);
                }
            }
        });

    }

    @Override
    public void onEventHappen(int eventCode, String message, Object object) {
        switch (eventCode) {
            case BaseObserver.REPORT_SUCCESS:
                doBanContent((Integer) object, "card");
                break;
        }
    }

    public void destoryObserver() {
        BaseObserver.getInstance().removeWatcher(TimelineListAdapter.class);
    }

    class OnClick implements View.OnClickListener {

        int position;
        Timeline mItem;
        int timelineType;

        public OnClick(int position) {
            this.position = position;
            this.mItem = tlist.get(position);
            timelineType = TimelineFactory.whichType(mItem);
        }

        @Override
        public void onClick(final View v) {
            switch (v.getId()) {
                case R.id.daily_teamname_rly:
                case R.id.group_view_container:
                    gotoUtil.gotoAct(mContext, NewTeamDetailActivity.class, mItem.getGid(), mItem.getGname());
                    break;
                case R.id.ground_name_tv:
                case R.id.ground_head_img:
                case R.id.ground_work_img:
                    if (timelineType == TimelineFactory.TIMELINE_TYPE_ASK) {
                        if (mItem.getDetails() != null && mItem.getDetails().size() > 0) {
                            gotoUtil.gotoAct(mContext, SmoothPersonActivity.class, mItem.getOuid());
                        } else {
                            gotoUtil.gotoAct(mContext, SmoothPersonActivity.class, mItem.getUid());
                        }
                    } else {
                        if (StringUtil.notNullEqual(mItem.getTl_type(), "work") || StringUtil.notNullEqual(mItem.getTl_type(), "site_work")) {
                            gotoUtil.gotoAct(mContext, CircleSmoothActivity.class, mItem.getRealName(), mItem.getWid());
                        } else if (StringUtil.notNullEqual(mItem.getTl_type(), "tag") || StringUtil.notNullEqual(mItem.getTl_type(), "site_tag")) {
                            Intent intent = new Intent(mContext, CircleTagSmoothActivity.class);
                            intent.putExtra("type", "tag");
                            intent.putExtra(gotoUtil.INTENT_VALUE_ONE, mItem.getTag_name());
                            mContext.startActivity(intent);
                        } else if (StringUtil.notNullEqual(mItem.getTl_type(), "group")) {
                            Intent intent = new Intent(mContext, TeamsActivity.class);
                            intent.putExtra("uid", UserDataHelper.getInstance(mContext).getUid());
                            intent.putExtra("groupNum", "0");
                            mContext.startActivity(intent);
                        } else {
                            gotoUtil.gotoAct(mContext, SmoothPersonActivity.class, mItem.getUid());
                        }
                    }
                    break;
                case R.id.timeline_answer_head_img:
                    if ("1".equals(mItem.getDetail().getAnonymous())) return;
                    gotoUtil.gotoAct(mContext, SmoothPersonActivity.class, mItem.getDetail().getCuid());
                    break;
                case R.id.civ_askmore_one:
                    if ("1".equals(mItem.getDetails().get(0).getAnonymous())) return;
                    gotoUtil.gotoAct(mContext, SmoothPersonActivity.class, mItem.getDetails().get(0).getCuid());
                    break;
                case R.id.civ_askmore_two:
                    if ("1".equals(mItem.getDetails().get(1).getAnonymous())) return;
                    gotoUtil.gotoAct(mContext, SmoothPersonActivity.class, mItem.getDetails().get(1).getCuid());
                    break;
                case R.id.civ_askmore_three:
                    if ("1".equals(mItem.getDetails().get(2).getAnonymous())) return;
                    gotoUtil.gotoAct(mContext, SmoothPersonActivity.class, mItem.getDetails().get(2).getCuid());
                    break;
                case R.id.ground_content_img:
                case R.id.ground_intro_tv:
                case R.id.ground_content_rly:
                case R.id.ground_intro_content:
                case R.id.daily_teamname_tv:
                case R.id.article_click:
                    switch (timelineType) {
                        case TimelineFactory.TIMELINE_TYPE_COSER:
                            DetailDataHelper.gotoCosDetail(mContext, mItem.getRp_id(), mItem.getCp_id(), false);
                            break;
                        case TimelineFactory.TIMELINE_TYPE_ILLUST:
                            DetailDataHelper.gotoDrawerDetail(mContext, mItem.getRp_id(), mItem.getDp_id(), false);
                            break;
                        case TimelineFactory.TIMELINE_TYPE_WRITER:
                            DetailDataHelper.gotoWriterDetail(mContext, mItem.getRp_id(), mItem.getWp_id(), false);
                            break;
                        case TimelineFactory.TIMELINE_TYPE_GOODS:
                            gotoUtil.gotoAct(mContext, GoodsDetailActivity.class, mItem.getZg_id());
                            break;
                        case TimelineFactory.TIMELINE_TYPE_DAILY:
                            DetailDataHelper.gotoDailyDetail(mContext, mItem.getUd_id(), false);
                            break;
                    }
                    break;
                case R.id.daily_intro_tv:
                case R.id.rl_daily_pics:
                    switch (timelineType) {
                        case TimelineFactory.TIMELINE_TYPE_DAILY:
                            DetailDataHelper.gotoDailyDetail(mContext, mItem.getUd_id(), false);
                            break;
                        case TimelineFactory.TIMELINE_TYPE_GROUP:
                            DetailDataHelper.gotoGroupDetail(mContext, mItem.getGid(), mItem.getPost_id(), false);
                            break;
                    }
                    break;
                case R.id.ground_like_rly:
                    if (isAnimation_runing) break;
                    TimelineLikeHelper.doLikeAll(mContext, mQueue, mItem, new TimelineLikeHelper.TimelineSuccess() {
                        @Override
                        public void onTimelineSuccess() {
                            if (!Boolean.parseBoolean(mItem.getHaveDing())) {
                                mItem.setHaveDing(String.valueOf(true));
                                mItem.setLikeNum(StringUtil.getString(
                                        StringUtil.getInt(mItem.getLikeNum()) + 1));
                            } else {
                                mItem.setHaveDing(String.valueOf(false));
                                mItem.setLikeNum(StringUtil.getString(
                                        StringUtil.getInt(mItem.getLikeNum()) - 1));
                            }
                            renderPaise(v, mItem);
                        }
                    });
                    break;
                case R.id.ll:
                    gotoUtil.gotoAct(mContext, AskActivity.class, mItem.getOuid(), mItem.getOUName());
                    break;
                case R.id.ground_comment_rly:
                    switch (timelineType) {
                        case TimelineFactory.TIMELINE_TYPE_COSER:
                            DetailDataHelper.gotoCosDetail(mContext, mItem.getRp_id(), mItem.getCp_id(), true);
                            break;
                        case TimelineFactory.TIMELINE_TYPE_ILLUST:
                            DetailDataHelper.gotoDrawerDetail(mContext, mItem.getRp_id(), mItem.getDp_id(), true);
                            break;
                        case TimelineFactory.TIMELINE_TYPE_DAILY:
                            DetailDataHelper.gotoDailyDetail(mContext, mItem.getUd_id(), true);
                            break;
                        case TimelineFactory.TIMELINE_TYPE_GROUP:
                            DetailDataHelper.gotoGroupDetail(mContext, mItem.getGid(), mItem.getPost_id(), true);
                            break;
                        case TimelineFactory.TIMELINE_TYPE_WRITER:
                            DetailDataHelper.gotoWriterDetail(mContext, mItem.getRp_id(), mItem.getWp_id(), true);
                            break;
                        case TimelineFactory.TIMELINE_TYPE_ASK:
                            gotoUtil.gotoAct(mContext, AskActivity.class, mItem.getOuid(), mItem.getOUName());
                            break;
                        case TimelineFactory.TIMELINE_TYPE_GOODS:
                            gotoUtil.gotoAct(mContext, GoodsDetailActivity.class, mItem.getZg_id());
                            break;
                    }
                    break;
                case R.id.timeline_ask_answer_tv:
                    gotoUtil.gotoAct(mContext, AskActivity.class, mItem.getOuid(), mItem.getOUName());
                    break;
                case R.id.ground_recommend_rly:
                    TimelineLikeHelper.doRecommendAll(mContext, mQueue, mItem, new TimelineLikeHelper.TimelineSuccess() {
                        @Override
                        public void onTimelineSuccess() {
                            mItem.setHaveRecommend(String.valueOf(!Boolean.valueOf(mItem.getHaveRecommend())));
                            renderRecommend(v, mItem);
                        }
                    });
                    break;
                case R.id.write_cover:
                    DetailDataHelper.gotoWriterDetail(mContext, mItem.getRp_id(), mItem.getWp_id(), false);
                    break;
                case R.id.ask_container:
                    gotoUtil.gotoAct(mContext, AskActivity.class, mItem.getOuid(), mItem.getOUName());
                    break;
                case R.id.topic_header:
                    gotoUtil.gotoAct(mContext, TopicDetailListActivity.class);
                case R.id.topic_cover:
                    gotoUtil.gotoAct(mContext, TopicDetailActivity.class, mItem.getSpecial_id());
                    break;
                case R.id.tv_focus_circle:
                    if ("site_work".equals(mItem.getTl_type())) {
                        doWorkLike();
                    } else if ("site_tag".equals(mItem.getTl_type())) {
                        doTagLike();
                    }
                    break;
                default:
                    break;
            }
        }

        private void doTagLike() {
            CircleLikeHelper.doCircleLike(mContext, mItem.getTag_id(), "tag", "follow", new CircleLikeHelper.CircleLikeSuccess() {
                @Override
                public void onCircleLikeSuccess() {
                    try {
                        mItem.setTf_status("true");
                        notifyItemChanged(position);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        }

        private void doWorkLike() {
            CircleLikeHelper.doCircleLike(mContext, mItem.getWid(), "work", "follow", new CircleLikeHelper.CircleLikeSuccess() {
                @Override
                public void onCircleLikeSuccess() {
                    try {
                        mItem.setWf_status("true");
                        notifyItemChanged(position);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        }

    }

    private void renderPaise(View view, final Timeline mItem) {
        final ImageView iv = (ImageView) view.findViewById(R.id.ground_like_img);
        final TextView tv = (TextView) view.findViewById(R.id.ground_likenumber_tv);
        if (StringUtil.getHaveDingBoolean(mItem)) {
            isAnimation_runing = true;
            iv.setScaleY(2f);
            iv.setScaleX(2f);
            iv.setImageResource(R.drawable.frame_praise);
            AnimationDrawable drawable = (AnimationDrawable) iv.getDrawable();
            drawable.start();
            iv.postDelayed(new Runnable() {
                @Override
                public void run() {
                    iv.setScaleY(1f);
                    iv.setScaleX(1f);
                    iv.setImageResource(R.drawable.like_pink);
                    tv.setText(mItem.getLikeNum());
                    isAnimation_runing = false;
                }
            }, 24 * 20);
        } else {
            iv.setImageResource(R.drawable.like_grey);
            tv.setText(mItem.getLikeNum());
            if (mItem.getLikeNum().equals("0")) {
                tv.setText(mContext.getString(R.string.good));
            }
        }
    }

    private void renderRecommend(View view, Timeline mItem) {
        TextView tv = (TextView) view.findViewById(R.id.ground_recommend_tv);
        if (StringUtil.notNullEqual(mItem.getHaveRecommend(), "true")) {
            tv.setText(mContext.getString(R.string.all_recommended));
        } else {
            tv.setText(mContext.getString(R.string.all_recommend));
        }
    }
}
